package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.bifang.module.base.common.vo.org.OrgTreeVO;
import com.bifang.module.base.common.vo.tree.TreeRetVO;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduFormEnroll.EduFormEnrollKeyVO;
import com.jwsoft.manager.common.vo.eduFormEnroll.EduFormEnrollQueryVO;
import com.jwsoft.manager.common.vo.eduFormEnroll.EduFormEnrollSchoolVO;
import com.jwsoft.manager.common.vo.eduFormEnroll.EduFormEnrollVO;
import com.jwsoft.manager.common.vo.eduFormEnrollParams.EduFormEnrollParamsVO;
import com.jwsoft.manager.common.vo.eduFormEnrollParams.SaveFormEnrollParamsVO;
import com.jwsoft.manager.common.vo.eduFormSpecial.FormSaveVO;
import com.jwsoft.manager.core.integration.EduFormEnrollIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 报名表单管理网关
 *
 * @author chenzh
 * @since 2023-02-10
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "报名表单管理", description = "报名表单管理")
public class EduFormEnrollController {

    @Autowired
    public EduFormEnrollIntegration eduFormEnrollIntegration;

    @Operation(summary = "报名表单管理分页查询",description = "报名表单管理分页查询")
    @PostMapping(value = "/eduFormEnroll0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduFormEnrollVO>> getList(@RequestBody @Validated EduFormEnrollQueryVO vo) {
        return AppResponse.successData(eduFormEnrollIntegration.getList(vo));
    }

    @Operation(summary = "报名表单管理根据主键查询详情",description = "报名表单管理根据主键查询详情")
    @PostMapping(value = "/eduFormEnroll0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduFormEnrollVO> getById(@RequestBody @Validated EduFormEnrollKeyVO vo) {
        return AppResponse.successData(eduFormEnrollIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "报名表单管理新增",description = "报名表单管理新增")
    @PostMapping(value = "/eduFormEnroll0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduFormEnrollVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduFormEnrollVO vo) {
        return AppResponse.successData(eduFormEnrollIntegration.save(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "报名表单管理修改",description = "报名表单管理修改")
    @PostMapping(value = "/eduFormEnroll0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduFormEnrollVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduFormEnrollVO vo) {
        return AppResponse.successData(eduFormEnrollIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "报名表单管理删除",description = "报名表单管理删除")
    @PostMapping(value = "/eduFormEnroll0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduFormEnrollKeyVO vo) {
        eduFormEnrollIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
    @Operation(summary = "根据表单id获取表单字段配置信息",description = "根据表单id获取表单字段配置信息")
    @PostMapping(value = "/eduFormEnroll0007", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduFormEnrollParamsVO>> getParamsListByFormId(@RequestBody @Validated EduFormEnrollKeyVO vo) {
        return AppResponse.successData(eduFormEnrollIntegration.getParamsListByFormId(vo));
    }
    @Operation(summary = "根据学校id获取表单配置信息 ",description = "根据表单id获取表单字段配置信息")
    @PostMapping(value = "/eduFormEnroll0008", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduFormEnrollVO>> getFormListBySchoolId(@RequestBody @Validated EduFormEnrollSchoolVO vo) {
        return AppResponse.successData(eduFormEnrollIntegration.getFormListBySchoolId(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "保存义务教育固定表单信息",description = "保存义务教育固定表单信息")
    @PostMapping(value = "/eduFormEnroll0009", produces = "application/json;charset=UTF-8")
    public AppResponse saveYwFixedFormInfo(@RequestBody @Validated FormSaveVO vo) {
        eduFormEnrollIntegration.saveYwFixedFormInfo(vo);
        return AppResponse.success();
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "动态表单字段配置保存",description = "动态表单字段配置保存")
    @PostMapping(value = "/eduFormEnroll0012", produces = "application/json;charset=UTF-8")
    public AppResponse saveFormEnrollParams(@RequestBody @Validated SaveFormEnrollParamsVO vo) {
        eduFormEnrollIntegration.saveFormEnrollParams(vo);
        return AppResponse.success();
    }

    @Operation(summary = "获取报名字段模板",description = "获取报名字段模板")
    @PostMapping(value = "/eduFormEnroll0015", produces = "application/json;charset=UTF-8")
    public AppResponse<TreeRetVO> getFormEmrollPramTreeList(@RequestBody @Validated OrgTreeVO vo) {
        return AppResponse.successData(eduFormEnrollIntegration.getFormEmrollPramTreeList(vo));
    }

}
